package com.yaofeng.mybatis.common;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.io.Serializable;
import java.util.List;

/**
 * 分页工具  分页信息
 * Created by yaofeng on 2019/8/30.
 */

@Setter
@Getter
@NoArgsConstructor
public class PageInfo implements Serializable {

    private static final long serialVersionUID = 8083750036892247499L;

    /**
     * 总记录数
     */
    private Long totalCount;
    /**
     * 每页记录数
     */
    private Long pageSize;
    /**
     * 总页数
     */
    private Long totalPage;
    /**
     * 当前页数
     */
    private Long currPage;
    /**
     * 列表数据
     */
    private List<?> list;


    /**
     * 分页
     */
    public PageInfo(IPage<?> page) {
        this.list =  page.getRecords();
        this.totalCount = page.getTotal();
        this.pageSize = page.getSize();
        this.currPage = page.getCurrent();
        this.totalPage =page.getPages();
    }

}
